########################################################################################################
### Replication of Figures 2 & 3 from "The impact of party cues on manual coding of political texts" ###
### (Ennser-Jedenastik & Meyer), Political Science Research and Methods ################################
########################################################################################################

## please set working directory to folder where data files are stored

### read in data
f2 <- read.csv("fig2_data.csv", header=T, sep=";")
f3 <- read.csv("fig3_data.csv", header=T, sep=";")

### labels for graphing
labs <- c(expression(paste(Delta, "Pr(Y=-1)")), expression(paste(Delta, "Pr(Y=0)")),
          expression(paste(Delta, "Pr(Y=1)")))

## graphing parameters:
cex <- 1
ylo <- 0.8
yhi <- 3.4
d <- 0.2


#################
### Figure 2: ###
#################

png("Figure 2.png", height = 10, width = 14, units = "cm", res=600)

par(mar=c(4,1,2,1), mfrow=c(1, 2))
plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(0.8, 3.4), axes=F, xlab="", ylab="", main="Greens", font.main=2)
abline(v=0, col="grey70", lty=3)
points(f2$dydx[1:3], 1:3, pch=19)
for (i in 1:3) lines(c(f2$cilo[i], f2$cihi[i]), c(i, i))
text(f2$dydx[1:3], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=1)

plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(0.8, 3.4), axes=F, xlab="", ylab="", main="FPOe")
abline(v=0, col="grey70", lty=3)
points(f2$dydx[4:6], 1:3, pch=19)
for (i in 1:3) lines(c(f2$cilo[i+3], f2$cihi[i+3]), c(i, i))
text(f2$dydx[4:6], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=1)

dev.off()





#################
### Figure 3: ###
#################

png("Figure 3.png", height = 12, width = 16, units = "cm", res=600)
par(mar=c(4,1,2,0), mfrow=c(2, 3), oma=c(0,3,0,0))

### GREENS:
plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(ylo, yhi), axes=F, xlab="", ylab="", main="Clearly negative statement")
abline(v=0, col="grey70", lty=3)
points(f3$dydx_sp[1:3], 1:3, pch=19)
for (i in 1:3) lines(c(f3$cilo_sp[i], f3$cihi_sp[i]), c(i, i))
text(f3$dydx_sp[1:3], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=cex)

plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(ylo, yhi), axes=F, xlab="", ylab="", main="Ambiguous statement")
abline(v=0, col="grey70", lty=3)
points(f3$dydx_sp[4:6], 1:3, pch=19)
for (i in 1:3) lines(c(f3$cilo_sp[i+3], f3$cihi_sp[i+3]), c(i, i))
text(f3$dydx_sp[4:6], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=cex)

plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(ylo, yhi), axes=F, xlab="", ylab="", main="Clearly positive statement")
abline(v=0, col="grey70", lty=3)
points(f3$dydx_sp[7:9], 1:3, pch=19)
for (i in 1:3) lines(c(f3$cilo_sp[i+6], f3$cihi_sp[i+6]), c(i, i))
text(f3$dydx_sp[7:9], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=cex)

### FPOe:
plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(ylo, yhi), axes=F, xlab="", ylab="", main="Clearly negative statement")
abline(v=0, col="grey70", lty=3)
points(f3$dydx_sp[10:12], 1:3, pch=19)
for (i in 1:3) lines(c(f3$cilo_sp[i+9], f3$cihi_sp[i+9]), c(i, i))
text(f3$dydx_sp[10:12], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=cex)

plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(ylo, yhi), axes=F, xlab="", ylab="", main="Ambiguous statement")
abline(v=0, col="grey70", lty=3)
points(f3$dydx_sp[13:15], 1:3, pch=19)
for (i in 1:3) lines(c(f3$cilo_sp[i+12], f3$cihi_sp[i+12]), c(i, i))
text(f3$dydx_sp[13:15], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=cex)

plot(NA, NA, xlim=c(-0.4, 0.4), ylim=c(ylo, yhi), axes=F, xlab="", ylab="", main="Clearly positive statement")
abline(v=0, col="grey70", lty=3)
points(f3$dydx_sp[16:18], 1:3, pch=19)
for (i in 1:3) lines(c(f3$cilo_sp[i+15], f3$cihi_sp[i+15]), c(i, i))
text(f3$dydx_sp[16:18], 1:3, labels=labs, cex=cex, pos=3)
axis(1, cex.axis=cex)

mtext("Greens vs. SPOe", side = 2, line = 0, outer=T, at=0.75, adj=0.3)
mtext("FPOe vs. SPOe", side = 2, line = 0, outer=T, at=0.25, adj=0.3)

dev.off()
